#ifndef CARNUM_H
#define CARNUM_H

#include <QObject>
#include <QObject>
#include <QTcpSocket>
#include <QWidget>
#include <opencv2/opencv.hpp>
#include <opencv2/objdetect.hpp>
#include <vector>
#include <iostream>
#include <fstream>

#include <QByteArray>
#include <QUrl>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QImage>
#include <QBuffer>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QUrlQuery>
#include <QDebug>
#include <QCoreApplication>
#include <QApplication>
#include <QMessageBox>
#include <QTimer>


using namespace cv;
using namespace std;

class Carnum : public QObject
{
    Q_OBJECT
public:
    explicit Carnum(QImage &image);
    ~Carnum();
     void run();//创建连接

signals:
    void picDataReceived(QImage);//车辆图片信息
    void numDataReceived(QString);//车牌信息
public slots:
    void recvimage();//获取图片
    void get();//获取轮廓
    void recognition();//图片类型转换
    void handleRespose();//获取号码值

private:
    QTcpSocket *socket;
    QImage &image;

    QNetworkReply *reply;
    QNetworkAccessManager manager;
    CascadeClassifier classifier;
    std::vector<Rect> plates;// 用于保存检测到的车牌的矩形框
    QByteArray jpegData;
    bool flag_emit = true;
    QStringList list;
    Mat grayImage;
    Mat img;
    int carcount;


    uint64_t fileSize = 0;
    bool waitingForSize = true;

};

#endif // CARNUM_H
